/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package py.com.sole.model;

import java.io.Serializable;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import static javax.persistence.CascadeType.MERGE;
import static javax.persistence.CascadeType.PERSIST;
import static javax.persistence.CascadeType.REFRESH;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.Table;
import javax.xml.bind.annotation.XmlRootElement;

/**
 *
 * @author bala
 */
@Entity
@Table(name = "articulos")
@XmlRootElement
@NamedQueries({
  @NamedQuery(name = "Articulo.findAll", query = "SELECT a FROM Articulo a where a.activo=TRUE"),
  @NamedQuery(name = "Articulo.findById", query = "SELECT a FROM Articulo a WHERE a.id = :id and a.activo=TRUE"),
  @NamedQuery(name = "Articulo.findByDescripcion", query = "SELECT a FROM Articulo a WHERE a.descripcion = :descripcion and a.activo=TRUE")})

public class Articulo implements Serializable {

  private static final long serialVersionUID = 1L;
  @Id
  @GeneratedValue(strategy = GenerationType.IDENTITY)
  @Basic(optional = false)
  @Column(nullable = false)
  private Integer id;
  @Basic(optional = false)
  @Column(nullable = false, length = 255)
  private String descripcion;
  @Basic(optional = false)
  @Column(name = "precio_adquisicion", nullable = false)
  private Double precioAdquisicion;
  @Basic(optional = false)
  @Column(name = "precio_venta", nullable = false)
  private Double precioVenta;
  @Basic(optional = false)
  @Column(nullable = false)
  private Integer existencia;
  @JoinColumn(name = "proveedor", referencedColumnName = "id", nullable = false)
  @ManyToOne(optional = false, cascade = {PERSIST, MERGE, REFRESH})
  private Proveedor proveedor;
  @JoinColumn(name = "tipo_articulo", referencedColumnName = "id", nullable = false)
  @ManyToOne(optional = false, cascade = {PERSIST, MERGE, REFRESH})
  private TipoArticulo tipoArticulo;
  @Basic(optional = false)
  @Column(nullable = false, length = 45)
  private String sector;
  private Boolean activo;

  public Articulo() {
  }

  public Articulo(Integer id) {
    this.id = id;
  }

  public Integer getId() {
    return id;
  }

  public void setId(Integer id) {
    this.id = id;
  }

  public String getDescripcion() {
    return descripcion;
  }

  public void setDescripcion(String descripcion) {
    this.descripcion = descripcion;
  }

  public Double getPrecioAdquisicion() {
    return precioAdquisicion;
  }

  public void setPrecioAdquisicion(Double precioAdquisicion) {
    this.precioAdquisicion = precioAdquisicion;
  }

  public Double getPrecioVenta() {
    return precioVenta;
  }

  public void setPrecioVenta(Double precioVenta) {
    this.precioVenta = precioVenta;
  }

  public Integer getExistencia() {
    return existencia;
  }

  public void setExistencia(Integer existencia) {
    this.existencia = existencia;
  }

  public Proveedor getProveedor() {
    return proveedor;
  }

  public void setProveedor(Proveedor proveedor) {
    this.proveedor = proveedor;
  }

  public TipoArticulo getTipoArticulo() {
    return tipoArticulo;
  }

  public void setTipoArticulo(TipoArticulo tipoArticulo) {
    this.tipoArticulo = tipoArticulo;
  }

  public String getSector() {
    return sector;
  }

  public void setSector(String sector) {
    this.sector = sector;
  }

  public Boolean isActivo() {
    return activo;
  }

  public void setActivo(Boolean activo) {
    this.activo = activo;
  }

  @Override
  public int hashCode() {
    int hash = 0;
    hash += (id != null ? id.hashCode() : 0);
    return hash;
  }

  @Override
  public boolean equals(Object object) {
    // TODO: Warning - this method won't work in the case the id fields are not set
    if (!(object instanceof Articulo)) {
      return false;
    }
    Articulo other = (Articulo) object;
    if ((this.id == null && other.id != null) || (this.id != null && !this.id.equals(other.id))) {
      return false;
    }
    return true;
  }

  @Override
  public String toString() {
    return "py.com.sole.model.Articulo[ id=" + id + " ]";
  }
}
